<template>
  <div class="programCard">
    <div class="program-title">
      <div>
        <span>大厅通知屏幕</span>
        <span>192*96</span>
      </div>
      <div>
        <a-button
          class="nbcs-btn nbcs-btn-danger"
          >停止播放</a-button>
      </div>
    </div>
    <div class="program-table">
      <a-table
      :columns="columns"
      :data-source="list"
      :pagination="pageConfig"
      rowKey="id"
      :loading="loading"
      :scroll="{ x: 1000}"
    >
      <span slot="action" slot-scope="text, record">
        <a @click="edit(1, record)">上移</a>
        <a @click="edit(1, record)">下移</a>
        <a-popconfirm title="确定删除该用户吗？" @confirm="del(record)">
          <a-icon slot="icon" type="question-circle-o" style="color: red" />
          <a class="table-red-btn">删除</a>
        </a-popconfirm>
      </span>
    </a-table>
    </div>
  </div>
</template>

<script>
import { change } from "@/services/tenant";
export default {
  name: "companyCard",
  data() {
    return {
      loading: false,
      list: [],
      columns: [
        { title: "节目",dataIndex: "realName" },
        { title: "操作人员", dataIndex: "username" },
        {
          title: "操作",
          key: "operation",
          fixed: "right",
          width: 300,
          scopedSlots: { customRender: "action" }
        }
      ],
      pageConfig: {
        showQuickJumper: true,
        showSizeChanger: true,
        defaultPageSize: 20,
        pageSizeOptions: ["20", "30", "50"],
        total: 0,
        showTotal: total => {
          return `共 ${total} 条`;
        }
      },
      page: {
        currentPage: 1,
        pageSize: 20
      }
    };
  },
  props: {
    
  },
  methods: {
    goClient(tenantId){
      console.log(window.location.host);
      let host = window.location.host;
      if(host.indexOf('localhost') == -1){
        let ip = host.split(':')[0]
        window.open(`http://${ip}:28080/#/loading?tenantId=${tenantId}`);
      } else{
        window.open(`http://192.168.10.199:28080/#/loading?tenantId=${tenantId}`);
      }
    },
    goDevice(id){
      this.$router.push({ path: "companyDevice", query: { id: id } });
    },
    control(id, status, index) {
      console.log(index)
      status = status == "0" ? "9" : "0";
      change({ id: id, status: status }).then(({data}) => {
        if (data.code != 0) {
          this.$message.error(data.message);
        } else {
          this.$message.success("操作成功");
          this.$emit("refreshList", { index: index, status: status });
        }
      });
    },
    showListEmit(id) {
      this.$emit("showListEmit", id);
    },
    play(mac, state) {
      if (state == 2) {
        this.$message.info("设备已停用，请启用后重试");
        return false;
      }
      this.$emit("play", mac);
    }
  }
};
</script>

<style lang="less" scoped>
.programCard{
  padding: 12px 20px;
  border-radius: 4px;
}
.program-title{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom:12px;
  & div:first-child{
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }
  & span:first-child{
    font-size: 18px;
    font-weight: bold;
    margin-right: 10px;
  }
  & span:last-of-type{
    font-size: 12px;
    color: #bbb;
  }
}
</style>
